package cn.lzd.mr.case1;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * Created by lzd on 2018/5/31.
 */
public class Bean implements Writable {

    private int upflow;
    private int downflow;
    private String phone;
    private int amountflow;

    public Bean() {
    }

    public Bean(int upflow, int downflow, String phone) {
        this.upflow = upflow;
        this.downflow = downflow;
        this.phone = phone;
        this.amountflow = this.upflow + downflow;
    }

    public void setUpflow(int upflow) {
        this.upflow = upflow;
    }

    public void setDownflow(int downflow) {
        this.downflow = downflow;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public void setAmountflow(int amountflow) {
        this.amountflow = amountflow;
    }

    public int getUpflow() {
        return upflow;
    }

    public int getDownflow() {
        return downflow;
    }

    public String getPhone() {
        return phone;
    }

    public int getAmountflow() {
        return amountflow;
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeInt(this.upflow);
        dataOutput.writeInt(this.downflow);
        dataOutput.writeUTF(this.getPhone());
        dataOutput.writeInt(this.amountflow);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.upflow = dataInput.readInt();
        this.downflow = dataInput.readInt();
        this.phone = dataInput.readUTF();
        this.amountflow = dataInput.readInt();
    }

    @Override
    public String toString() {
        return upflow + "\t" + downflow + "\t" + phone + "\t" + amountflow;
    }
}
